<include file="Common/header" />
<!-- 顶部 -->     
<div id="middle">
    <include file="Common/menu" />
    <div class="right" id="mainFrame">
		<div class="right_cont">
			<ul class="breadcrumb">当前位置：
				<a href="javascript:void(0);">首页</a> <span class="divider">/</span>
				<a href="javascript:void(0);">会员管理</a> <span class="divider">/</span>
				添加会员
			</ul>
			<div class="title_right"><strong>基本信息</strong></div>
			<form action="" method="POST" id="addfrom">
				<div style="width: 90%; margin:auto">
					<table class="table table-bordered">
						<tr>
							<td width="20%" align="right" bgcolor="#f1f1f1">合同编号：</td>
							<td>
								<input type="text" name="contract" id="contract" class="span1-3" value="{$userinfo['contract']}" />
								<span class="passwordabel"></span>
							</td>
							<td width="20%" align="right" bgcolor="#f1f1f1">客人姓名：</td>
							<td>
								<input type="hidden" name="member_id" id="member_id" value="{$userinfo['member_id']}" />
								<input type="text" name="member_nick" id="member_nick" class="span1-3" value="{$userinfo['member_nick']}" />
								<span class="usernameabel"></span>
							</td>
							<td width="20%" align="right" bgcolor="#f1f1f1">身份证：</td>
							<td>
								<input type="text" name="member_card" id="member_card" class="span1-3" value="{$userinfo['member_card']}" />
								<span class="passwordabel"></span>
							</td>
							<td width="20%" align="right" bgcolor="#f1f1f1">联系方式：</td>
							<td>
								<input type="text" name="member_phone" id="member_phone" class="span1-3" value="{$userinfo['member_phone']}" />
								<span class="nicknameabel"></span>
							</td>
						</tr>
						<tr>
							<td width="20%" align="right" bgcolor="#f1f1f1">房间号：</td>
							<td>
								<input type="text" name="room_number" id="room_number" class="span1-3" value="{$userinfo['room_number']}" />
								<span class="nicknameabel"></span>
							</td>
							<td width="20%" align="right" bgcolor="#f1f1f1">押金：</td>
							<td>
								<input type="text" name="deposit" id="deposit" class="span1-3" value="{$userinfo['deposit']}" />
								<span class="nicknameabel"></span>
							</td>
						
							<td width="20%" align="right" bgcolor="#f1f1f1">缴费时间：</td>
							<td>
								<input type="text" name="checkin_time" id="checkin_time" class="laydate-icon span1-3" value="<?php echo $userinfo['member_id'] ? date('Y-m-d H:i', $userinfo['checkin_time']) : '';?>" />
								<span class="nicknameabel"></span>
							</td>
							<td width="20%" align="right" bgcolor="#f1f1f1">费用截止时间：</td>
							<td>
								<input type="text" name="leaving_time" id="leaving_time" class="laydate-icon span1-3" value="<?php echo $userinfo['member_id'] ? date('Y-m-d H:i', $userinfo['leaving_time']) : '';?>" />
								<span class="nicknameabel"></span>
							</td>
						</tr>
						<tr>
							<td width="20%" align="right" bgcolor="#f1f1f1">合同开始时间：</td>
							<td>
								<input type="text" name="btime" id="btime" class="laydate-icon span1-3" value="<?php echo $userinfo['member_id'] ? date('Y-m-d H:i', $userinfo['btime']) : '';?>" />
								<span class="nicknameabel"></span>
							</td>
							<td width="20%" align="right" bgcolor="#f1f1f1">合同终止时间：</td>
							<td>
								<input type="text" name="etime" id="etime" class="laydate-icon span1-3" value="<?php echo $userinfo['member_id'] ? date('Y-m-d H:i', $userinfo['etime']) : '';?>" />
								<span class="nicknameabel"></span>
							</td>
							<td width="20%" align="right" bgcolor="#f1f1f1"></td>
							<td>
								
							</td>
							<td width="20%" align="right" bgcolor="#f1f1f1"></td>
							<td>
								
							</td>
						</tr>
						<tr>
							<td width="20%" align="right" bgcolor="#f1f1f1">租房类型：</td>
							<td>
								<select id="type" name="type">
									<option value="长租" selected="">长租</option>
									<option value="短租">短租</option>
								</select>
								<span class="nicknameabel"></span>
							</td>
						
							<td width="20%" align="right" bgcolor="#f1f1f1">水表起始度数：</td>
							<td>
								<input type="text" name="eqment_1" id="eqment_1" class="span1-3" value="" />
								<span class="nicknameabel"></span>
							</td>
							<td width="20%" align="right" bgcolor="#f1f1f1">电表起始度数：</td>
							<td>
								<input type="text" name="eqment_2" id="eqment_2" class="span1-3" value="" />
								<span class="nicknameabel"></span>
							</td>
							<td width="20%" align="right" bgcolor="#f1f1f1">气表起始度数：</td>
							<td>
								<input type="text" name="eqment_3" id="eqment_3" class="span1-3" value="" />
								<span class="nicknameabel"></span>
							</td>
						</tr>
						<tr>
							<td width="20%" align="center" colspan="6"><b style="color: red;">如果水电气起始度数手动填写，系统将以手动输入的数据为准。</b></td>
						</tr>
					</table>
					
					<table  class="margin-bottom-20 table  no-border" >
						<tr>
							<td class="text-center">
								<input type="button" value="确定" class="btn btn-info roleSubmit" style="width:80px;" />
								<a href="excel.html">
									<input type="button" value="导出Excel" class="btn btn-warning" style="width:80px;" />
								</a>
							</td>
						</tr>
					</table>
				</div>
			</form>
			<div class="title_right"><strong>会员导入</strong></div>
			<div style="width: 900px; margin:auto">
				<form enctype="multipart/form-data" id="fileup" action="import.html" method="post">
					<table class="table table-bordered">
						<tr>
							<td width="20%" align="right" bgcolor="#f1f1f1">Excel文件：</td>
							<td>
								<input type="file" name="file" id="file" class="span1-3" value="" />
								<input type="button" value="导入" class="btn btn-success filesure" style="width:80px;" />
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div class="title_right"><strong>按条件搜索</strong></div>  
			<div style="width: 900px; margin:auto">
				<table class="table table-bordered">
					<tr>
						<td width="20%" align="right" bgcolor="#f1f1f1">房间号：</td>
						<td>
							<input type="text" name="roomnumber" id="roomnumber" class="span1-3" value="" />
							<span class="passwordabel"></span>
							<input type="button" value="查询" class="btn btn-info querysInfo" style="width:80px;" />
						</td>
					</tr>
				</table>
			</div>
			<div class="title_right"><strong>会员列表</strong></div>  
			<div style="width: 98%; margin:auto">
					<div id="ajaxDiv">
						<include file="Member/lists_page" />
					</div>
				</div>
			</div>
		</div>     
    </div>
</div>
<script>
	$(document).ready(function(){
		$(".roleSubmit").on('click', function(){
			if($("#checkin_time").val() == ""){
				layer.msg("请选择缴费时间", {icon: 2, time:2000});
				return false;
			}
			
			if($("#leaving_time").val() == ""){
				layer.msg("请选择费用截止时间", {icon: 2, time:2000});
				return false;
			}
			
			if($("#btime").val() == ""){
				layer.msg("请选择合同开始时间", {icon: 2, time:2000});
				return false;
			}
			
			if($("#etime").val() == ""){
				layer.msg("请选择合同截止时间", {icon: 2, time:2000});
				return false;
			}

			var load = layer.load(2);
			$.post('add.html', $("#addfrom").serialize(), function(data){
				layer.close(load);
				layer.msg(data, {icon: 1, time: 2000}, function(){
					location.reload();
				});
			});
		});

		//根据房间号获取历史数据
		$(".querysInfo").on('click', function(){
			var roomnumber = $("#roomnumber").val() || "";
			$.get('lists.html', {roomnumber: roomnumber, ajax: 1}, function(data){
				$("#ajaxDiv").html(data);
			});
		});

		//异步获取设备初始数值
		$('#room_number').on('keyup', function(){
			$.get('ajaxeqm.html', {roomnumber: $("#room_number").val()}, function(data){
				if(data.errCode/1){
					var eqment_1 = data.eqment_1/1 ? data.eqment_1 : 0;
					var eqment_2 = data.eqment_2/1 ? data.eqment_2 : 0;
					var eqment_3 = data.eqment_3/1 ? data.eqment_3 : 0;

					$("#eqment_1").val(eqment_1);
					$("#eqment_2").val(eqment_2);
					$("#eqment_3").val(eqment_3);
				}
			});
		});

		$(".filesure").on('click', function(){
			$("#fileup").submit();
		});
	});
</script>
<script>
	!function(){
		laydate.skin('molv');
		laydate({elem: '#checkin_time', format: "YYYY-MM-DD hh:mm:ss"});
		laydate({elem: '#leaving_time', format: "YYYY-MM-DD hh:mm:ss"});
		laydate({elem: '#btime', format: "YYYY-MM-DD hh:mm:ss"});
		laydate({elem: '#etime', format: "YYYY-MM-DD hh:mm:ss"});
	}();
</script>
<include file="Common/footer" />
